package cn.lasse.design;

import cn.lasse.design.model.AmericanMoney;
import cn.lasse.design.model.HandsomeBoy;
import cn.lasse.design.model.JapanMoney;
import cn.lasse.design.model.KoreaMoney;
import cn.lasse.design.bank.service.AmericanService;
import cn.lasse.design.bank.service.JapanService;
import cn.lasse.design.bank.service.KoreaService;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class BankController {

    public Integer bank(HandsomeBoy user, Integer type) {
        Integer rmb = user.getRmb();
        Integer money=0;
        try {
            // 按照不同类型方法商品[1美元、2韩元、3日元]
            if (type== 1) {
                AmericanService americanService = new AmericanService();
                AmericanMoney exchange = americanService.exchange(rmb);
                //噼里啪啦一堆逻辑。。。
                money=exchange.getMoney();
            } else if (type== 2) {
                KoreaService koreaService = new KoreaService();
                KoreaMoney exchange = koreaService.exchange(rmb);
                //噼里啪啦一堆逻辑。。。
                money=exchange.getMoney();
            } else if (type== 3) {
                JapanService japanService = new JapanService();
                JapanMoney exchange = japanService.exchange(rmb);
                //噼里啪啦一堆逻辑。。。
                money=exchange.getMoney();
            }
        } catch (Exception e) {
            log.error("货币兑换失败{}。{}" ,e);
        }
        return money;
    }
}
